package com.share.device.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.share.device.domain.Cabinet;
import com.share.device.mapper.CabinetMapper;
import com.share.device.service.ICabinetService;
import io.swagger.v3.oas.annotations.media.Schema;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.nio.file.Watchable;
import java.util.List;

@Service
public class CabinetServiceImpl extends ServiceImpl<CabinetMapper, Cabinet> implements ICabinetService {

    @Override
    public List<Cabinet> selectListCabinet(Cabinet cabinet) {
        return baseMapper.selectListCabinet(cabinet);
    }

    @Override
    public List<Cabinet> searchNoUseList(String cabinetNo) {
        return baseMapper.selectList(
                new LambdaQueryWrapper<Cabinet>()
                        .likeRight(Cabinet::getCabinetNo, cabinetNo)
                        .eq(Cabinet::getStatus, 0)
        );
    }

    @Override
    public Cabinet getBtCabinetNo(String cabinetNo) {
        return baseMapper.selectOne(
                new LambdaQueryWrapper<Cabinet>()
                        .eq(Cabinet::getCabinetNo, cabinetNo)
        );
    }

}
